package com.test.daily.leetcode.y2022.m06.day0605.v02;

import java.util.Random;

/**
 * @descriptions:
 * @author: Tom
 * @date: 2022/6/5 下午 12:03
 * @version: 1.0
 */
public class Solution {
    public Random random;
    public double radius;
    public double x_center;
    public double y_center;
    public Solution(double radius, double x_center, double y_center) {
        this.radius = radius;
        this.x_center = x_center;
        this.y_center = y_center;
        this.random = new Random();
    }

    public double[] randPoint() {
       while(true){
           double x = this.random.nextDouble() *(2*this.radius) - this.radius;
           double y = this.random.nextDouble()*(2*this.radius) - this.radius;
           if(x*x + y*y <= this.radius * this.radius){
               return new double[]{this.x_center+x,this.y_center + y};
           }
       }
    }
}
